<?php

namespace App\Imports;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;

class MyImport implements ToCollection
{
    public $excelData;

    public $table;
    /**
    * @param Collection $collection
    */
    public function collection(Collection $collection)
    {
        foreach ($collection as $key => $item) {
            if ($key == 0) {
                $temp = [];
                foreach ($item as $index => $value) {
                    if ($index > 7) {
                        if ($index == 14 || $index == 24) {
                            continue;
                        }
                        $temp[] = $value;
                    }
                }
                $this->table = $temp;
            } else {
                $tempArr = [];
                foreach ($item as $index => $value) {
                    if ($index > 7) {
                        if ($index == 14 || $index == 24) {
                            continue;
                        }
                        $tempArr[] = $value;
                    }
                }
                $this->excelData[] = $tempArr;
            }
        }

        return [$this->excelData, $this->table];
    }
}
